Visualize Latest Observations from the Ambient Weather Stations#
Imports#
import glob
import xarray as xr
from bokeh.models.formatters import DatetimeTickFormatter
import hvplot.xarray
import holoviews as hv
from distributed import Client
import warnings
warnings.filterwarnings("ignore")
hv.extension('bokeh')
Start up a Dask Cluster#
client = Client()
client
Client
Client-7c3d5a38-1145-11f0-8ae5-00224823a2a0
| Connection method: Cluster object | Cluster type: distributed.LocalCluster |
| Dashboard: http://127.0.0.1:8787/status |
Cluster Info
LocalCluster
eaaaa76c
| Dashboard: http://127.0.0.1:8787/status | Workers: 4 |
| Total threads: 4 | Total memory: 15.62 GiB |
| Status: running | Using processes: True |
Scheduler Info
Scheduler
Scheduler-a51bbfee-34e4-4e3c-966e-2c9d0adc7407
| Comm: tcp://127.0.0.1:41989 | Workers: 4 |
| Dashboard: http://127.0.0.1:8787/status | Total threads: 4 |
| Started: Just now | Total memory: 15.62 GiB |
Workers
Worker: 0
| Comm: tcp://127.0.0.1:45547 | Total threads: 1 |
| Dashboard: http://127.0.0.1:45365/status | Memory: 3.90 GiB |
| Nanny: tcp://127.0.0.1:38155 | |
| Local directory: /tmp/dask-scratch-space/worker-4u3v04_8 | |
Worker: 1
| Comm: tcp://127.0.0.1:34031 | Total threads: 1 |
| Dashboard: http://127.0.0.1:39107/status | Memory: 3.90 GiB |
| Nanny: tcp://127.0.0.1:36877 | |
| Local directory: /tmp/dask-scratch-space/worker-yelj_m82 | |
Worker: 2
| Comm: tcp://127.0.0.1:33029 | Total threads: 1 |
| Dashboard: http://127.0.0.1:43147/status | Memory: 3.90 GiB |
| Nanny: tcp://127.0.0.1:43909 | |
| Local directory: /tmp/dask-scratch-space/worker-zeyxuel6 | |
Worker: 3
| Comm: tcp://127.0.0.1:40775 | Total threads: 1 |
| Dashboard: http://127.0.0.1:45505/status | Memory: 3.90 GiB |
| Nanny: tcp://127.0.0.1:42015 | |
| Local directory: /tmp/dask-scratch-space/worker-ajhkbtay | |
Read the Sorted Data, Using the Last File#
files = sorted(glob.glob('../../data/surface-meteorology/*/*/*/*.nc'))
ds = xr.open_mfdataset(files[-60:])
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[3], line 3
1 files = sorted(glob.glob('../../data/surface-meteorology/*/*/*/*.nc'))
----> 3 ds = xr.open_mfdataset(files[-60:])
File ~/miniconda3/envs/instrument-cookbooks-dev/lib/python3.10/site-packages/xarray/backends/api.py:1597, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs)
1594 paths = _find_absolute_paths(paths, engine=engine, **kwargs)
1596 if not paths:
-> 1597 raise OSError("no files to open")
1599 paths1d: list[str | ReadBuffer]
1600 if combine == "nested":
OSError: no files to open
Plot the Data#
formatter = DatetimeTickFormatter(hours="%d %b %Y \n %H:%M UTC")
variables = ['outdoor_temperature', 'outdoor_dewpoint', 'hourlyrainin', 'solarradiation']
panels = []
for variable in variables:
panels.append(ds[variable].hvplot.line(x='time', by='station', xformatter=formatter))
hv.Layout(panels).cols(1)